#ifndef _BASICLED_H
#define _BASICLED_H
#include "BasicSpi.h"

#define uchar unsigned char

///////////////////////////
class CBasicLED
{
public:
	CBasicLED(CBasicSpi *pSpi);
	/***************************************
	* OLED SPI
	* rest		rest(OLED)
	* MOSI		SDA(OLED)
	* MISO		DC(OLED)
	* SCK		SCL(OLED)
	* SS		CS(OLED)
	* VCC		VCC(OLED)
	* GND		GND(OLED)
	***************************************/
	void begin();
	void begin(uchar DC, uchar CS, uchar RES);

	void sendScreen();
	void clearMemery(uchar data);
    	void clearMemery(){clearMemery(0);}
	void Enable(bool bChose = true);
    ~CBasicLED(){};

protected:
	void initLED();
	void reinitLED();
	void sendLED(uchar data, int bData=1);
	void setLedAddr(unsigned char nPage, unsigned char nColumn);
	void addAByte(uchar* buf, uchar x = 0, uchar y = 0);
	void setMemery(uchar* buf, int nLength, uchar x, uchar y);
	void setDigital(char* str, float  fData);
	bool IsUpdate(float data, int nChIdx);
	
protected:
	uchar LED_DC;
	uchar LED_RES;	
	uchar LED_CS;
	uchar m_nMem[8][128];
	CBasicSpi *pSpi;
};
#endif

